<template>
  <div class="top-bar">
    <div class="note">共找到<span>{{similarNum}}只</span>相似股票</div>
    <div class="bottom">
      <div class="num up">{{ upNum }}只次日上涨</div>
      <div class="percent-bar" :class="{'g-bg':upNum + downNum==0}">
        <div class="leftBar"></div>
        <div class="rightBar" :style="{width: downPercent+'%'}"></div>
      </div>
      <div class="num down">{{ downNum }}只次日下跌</div>
      <!--<div class="wenhao" @click.stop="toUpDown">-->
        <!--<i class="iconfont icon-wenhao"></i>-->
      <!--</div>-->
    </div>
  </div>
</template>

<script>
  const TDAPP = window.TDAPP

  export default {
    name: 'TopBar',
    data () {
      return {
      }
    },
    props: {
      upNum: {
        type: Number
      },
      downNum: {
        type: Number
      },
      similarNum: {
        type: Number
      },
      stock: {
        type: String
      },
      isShare: {
        type: Boolean
      }
    },
    computed: {
      upPercent () {
        if (this.similarNum <= 0) {
          return 0
        } else {
          return (this.upNum / this.similarNum * 100).toFixed(1)
        }
      },
      downPercent () {
        if (this.similarNum <= 0) {
          return 0
        } else {
          return (this.downNum / this.similarNum * 100).toFixed(1)
        }
      }
    },
    methods: {
      toUpDown () {
        let tdId = ''
        if (this.isShare) {
          tdId = '004025'
        } else {
          tdId = '004011'
        }
        TDAPP.onEvent(tdId, '', {userCode: '', stockCode: this.stock})
        TDAPP.send()
        this.$router.push('/upDown')
      }
    }
  }
</script>

<style lang="less" rel="stylesheet/less" scoped>
  .top-bar{
    background-color: #212138;
    width: 100%;
    height: 114px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    border-bottom: 1px solid #2e2e46;/*no*/
  }
  .note{
    font-size: 24px;
    line-height: 24px;
    color: #fff;
    margin-top: 2px;
    margin-bottom: 16px;
    opacity: 0.8;
    span{
      color: #ff8420;
    }
  }
  .bottom{
    display: flex;
    justify-content: center;
    align-items: center;
    padding-left: 34px;
    height: 28px;
    .wenhao {
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: flex-end;
      .icon-wenhao{
        color: #ff8420;
        font-size: 22px;
      }
    }
    .num {
      display: flex;
      justify-content: center;
      align-items: center;
      color: #555555;
      height: 20px;
      line-height: 20px;
      font-size: 20px;
      margin: 0 5px;
      opacity: 0.8;
    }
    .up{
        color:#eb333b
    }
    .down{
        color:#1aae52
    }
  }
  .percent-bar{
    border-radius: 7px;
    width: 404px;
    height: 6px;
    background: #eb333b;
    margin: 0 20px;
    opacity: 0.7;
    .leftBar{
      border-radius: 7px;
      height: 100%;
      float: left;
    }
    .rightBar{
      background-color: #19ae52;
      border-radius: 7px;
      height: 100%;
      display: inline;
      float: right;
    }
  }
</style>
